﻿function DatatableToolbarPlugin(options) {
	this.toolbar = null;
	
	
	this.attach = function(grid) {
		DataTable.prototype.addToolbarWidget = function(widget) {
			this._element.find('.dt-table-toolbar').css('display', '').append(widget);
		};
		
		DataTable.prototype.removeToolbarWidget = function(widget) {
			widget.remove();
			var tlb = this._element.find('.dt-table-toolbar');
			tlb.css('display', tlb.children().size() > 0 ? '': 'none');
		};
	
		this.toolbar = $('<div>').addClass('dt-table-toolbar ui-state-default');
		this.toolbar.insertAfter(grid._element.find('.dt-table-header'));
	};
	
	this.detach = function() {
		if (this.toolbar != null) this.toolbar.remove();
	}
}; DatatableToolbarPlugin.inherits(DatagridPlugin);